﻿package mortal.game.view.hangCount
{
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.pageSelect.*;
    import mortal.game.view.hangCount.renderer.*;
    import mortal.game.view.mainUI.zazen.*;

    public class HangCountWin extends RightDownShrinkView
    {
        private var _crossLabel1:GImageBitmap;
        private var _hangUpTime:SecTimerCountView;
        private var _gainExp:GTextFiled;
        private var _itemList:GTileList;
        private var _pageSelecter:PageSelecter;
        private const pageNum:int = 6;
        private static var _instance:HangCountWin;

        public function HangCountWin()
        {
            this.mouseEnabled = false;
            super(ImagesConst.GuajiaCrossDetail, ImagesConst.GuajiGet);
            setSize(288, 166);
            if (_instance)
            {
                throw new Error(" HangCountWin 单例 ");
            }
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_1:* = Game.mapInfo.mapId;
            if (MapFileUtil.isInLocalShowAutofightWinMap)
            {
                _titleImageName = ImagesConst.GuajiaDetail;
            }
            else
            {
                _titleImageName = ImagesConst.GuajiaCrossDetail;
            }
            super.createDisposedChildrenImpl();
            if (MapFileUtil.isInLocalShowAutofightWinMap)
            {
                this._crossLabel1 = UIFactory.gImageBitmap(ImagesConst.GuajiDes, 77, 43, _bodySprite);
            }
            else
            {
                this._crossLabel1 = UIFactory.gImageBitmap(ImagesConst.GuajiCrossDes, 77, 43, _bodySprite);
            }
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.GuajiTongjiLine, 0, 57, _bodySprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.GuajiTime, 18, 74, _bodySprite));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.GuajiExp, 146, 74, _bodySprite));
            var _loc_2:* = GlobalStyle.textFormatBai;
            _loc_2.size = 13;
            this._hangUpTime = UIFactory.secTimeCountView(Language.getString(21515), 82, 71, 90, 22, _bodySprite, _loc_2);
            this._gainExp = UIFactory.gTextField("0", 209, 71, 90, 22, _bodySprite, _loc_2.clone());
            this._itemList = UIFactory.tileList(15, 95, 266, 45, _bodySprite);
            this._itemList.columnWidth = 44;
            this._itemList.rowHeight = 41;
            this._itemList.horizontalGap = 0;
            this._itemList.verticalGap = 0;
            this._itemList.setStyle("skin", new Bitmap());
            this._itemList.setStyle("cellRenderer", HangCountItemListCellRenderer);
            var _loc_3:* = GlobalStyle.textFormatBai;
            _loc_3.align = AlignMode.CENTER;
            this._pageSelecter = UIFactory.pageSelecter(86, 140, _bodySprite, PageSelecter.CompleteMode);
            this._pageSelecter.setbgStlye(ImagesConst.InputDisablBg, _loc_3);
            this._pageSelecter.pageTextBoxSize = 50;
            this._pageSelecter.maxPage = 1;
            this._pageSelecter.configEventListener(Event.CHANGE, this.onPageChange);
            this.updateItemList();
            this.addListeners();
            return;
        }// end function

        private function addListeners() : void
        {
            return;
        }// end function

        private function removeListeners() : void
        {
            return;
        }// end function

        private function updateHangTime() : void
        {
            this._hangUpTime.startCount(60);
            return;
        }// end function

        public function updateTotalTime(param1:int) : void
        {
            this._hangUpTime.startCount(param1);
            return;
        }// end function

        private function updateKillMonsterNum() : void
        {
            return;
        }// end function

        public function updateGainExp() : void
        {
            var _loc_1:* = GameController.hangStatistics.totalGainExp;
            this._gainExp.text = _loc_1.toString();
            return;
        }// end function

        public function updateItemList() : void
        {
            var _loc_8:int = 0;
            var _loc_1:Array = [];
            var _loc_2:* = GameController.hangStatistics.itemArr;
            this.updatePageInfo();
            var _loc_3:* = this._pageSelecter.currentPage;
            var _loc_4:* = (_loc_3 - 1) * this.pageNum;
            var _loc_5:* = _loc_3 * this.pageNum;
            _loc_1 = _loc_2.slice(_loc_4, _loc_5);
            var _loc_6:* = _loc_1.length;
            if (_loc_6 < this.pageNum)
            {
                _loc_8 = 0;
                while (_loc_8 < this.pageNum - _loc_6)
                {
                    
                    _loc_1.push({});
                    _loc_8++;
                }
            }
            var _loc_7:* = new DataProvider();
            _loc_7.addItems(_loc_1);
            this._itemList.dataProvider = _loc_7;
            this._itemList.drawNow();
            return;
        }// end function

        private function updatePageInfo() : void
        {
            var _loc_1:* = GameController.hangStatistics.itemArr;
            this._pageSelecter.maxPage = Math.ceil(_loc_1.length / this.pageNum);
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            this.updateItemList();
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show();
            stageResize();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._gainExp.dispose();
            this._itemList.dispose();
            this._pageSelecter.dispose();
            this._hangUpTime.dispose();
            this._gainExp = null;
            this._itemList = null;
            this._pageSelecter = null;
            this._hangUpTime = null;
            this._crossLabel1.dispose(param1);
            this._crossLabel1 = null;
            this.removeListeners();
            return;
        }// end function

        public static function get instance() : HangCountWin
        {
            if (!_instance)
            {
                _instance = new HangCountWin;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
